#include "heartbeat.h"

HeartBeat::HeartBeat(QObject *parent) :
    QThread(parent)
{
    _isWorking = false;
    _timer=NULL;
}
HeartBeat::~HeartBeat()
{
    this->wait();
    if(_timer!=NULL)
    {
        delete _timer;
    }
}


void HeartBeat::run()
{
    qDebug()<<"HeartBeat::run()";
    _timer = new QTimer;
    connect(_timer, SIGNAL(timeout()), this, SLOT(giveABeat()));

    _timer->setInterval((60*1000)*10);
    _timer->start();
    exec();
}
void HeartBeat::giveABeat()
{
    qDebug()<<"HeartBeat::giveABeat()";
    if(_isWorking)  return;
    _isWorking = true;
    PelicanoMonitorWS ws;
    ws.heartBeat();
    _isWorking = false;
}
